package com.ruoyi.platform.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.platform.domain.TbBusinessCertificate;
import com.ruoyi.platform.service.ITbBusinessCertificateService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 经营许可证信息Controller
 * 
 * @author ruoyi
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/certificate")
public class TbBusinessCertificateController extends BaseController
{
    @Autowired
    private ITbBusinessCertificateService tbBusinessCertificateService;

    /**
     * 查询经营许可证信息列表
     */
    //@RequiresPermissions("platform:certificate:list")
    @GetMapping("/list")
    public TableDataInfo list(TbBusinessCertificate tbBusinessCertificate)
    {
        startPage();
        List<TbBusinessCertificate> list = tbBusinessCertificateService.selectTbBusinessCertificateList(tbBusinessCertificate);
        return getDataTable(list);
    }

    /**
     * 导出经营许可证信息列表
     */
    //@RequiresPermissions("platform:certificate:export")
    @Log(title = "经营许可证信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbBusinessCertificate tbBusinessCertificate)
    {
        List<TbBusinessCertificate> list = tbBusinessCertificateService.selectTbBusinessCertificateList(tbBusinessCertificate);
        ExcelUtil<TbBusinessCertificate> util = new ExcelUtil<TbBusinessCertificate>(TbBusinessCertificate.class);
        util.exportExcel(response, list, "经营许可证信息数据");
    }

    /**
     * 获取经营许可证信息详细信息
     */
    //@RequiresPermissions("platform:certificate:query")
    @GetMapping(value = "/{serviceInstitutionId}")
    public AjaxResult getInfo(@PathVariable("serviceInstitutionId") Long serviceInstitutionId)
    {
        return success(tbBusinessCertificateService.selectTbBusinessCertificateByServiceInstitutionId(serviceInstitutionId));
    }

    /**
     * 新增经营许可证信息
     */
    //@RequiresPermissions("platform:certificate:add")
    @Log(title = "经营许可证信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbBusinessCertificate tbBusinessCertificate)
    {
        return toAjax(tbBusinessCertificateService.insertTbBusinessCertificate(tbBusinessCertificate));
    }

    /**
     * 修改经营许可证信息
     */
    //@RequiresPermissions("platform:certificate:edit")
    @Log(title = "经营许可证信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbBusinessCertificate tbBusinessCertificate)
    {
        return toAjax(tbBusinessCertificateService.updateTbBusinessCertificate(tbBusinessCertificate));
    }

    /**
     * 删除经营许可证信息
     */
    //@RequiresPermissions("platform:certificate:remove")
    @Log(title = "经营许可证信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{serviceInstitutionIds}")
    public AjaxResult remove(@PathVariable Long[] serviceInstitutionIds)
    {
        return toAjax(tbBusinessCertificateService.deleteTbBusinessCertificateByServiceInstitutionIds(serviceInstitutionIds));
    }
}
